//============================================================
// Producnt name:		Wz
// Version: 			1.0
// Coded by:			Wz (13066628480@163.com)
// Auto generated at: 	2016/10/9 10:22:04
//============================================================

using System;
using System.Collections.Generic;
using System.Text;
using Cloud.Model;
using System.Data.SqlClient;
using System.Data;
namespace Cloud.DAL
{
	public static class ZS_TYPEINFOService
	{
		#region SqlCommandText
		private const string Save_CommandText = "insert into ZS_TYPEINFO values(@ID,@NAME,@EXT1)";
		private const string Update_CommandText = "Update ZS_TYPEINFO set NAME = @NAME,EXT1 = @EXT1 where ID = @ID";
		private const string Delete_CommandText = "delete from ZS_TYPEINFO where ID = @ID";
		private const string FindAll_CommandText = "select * from ZS_TYPEINFO";
		private const string FindById_CommandText = "select * from ZS_TYPEINFO where ID=@ID";
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region Save
		public static int Save(ZS_TYPEINFO zS_TYPEINFO)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@ID",SqlDbType.VarChar),
				new SqlParameter("@NAME",SqlDbType.VarChar),
				new SqlParameter("@EXT1",SqlDbType.Int)
				};
			pars[0].Value=zS_TYPEINFO.ID;
			pars[1].Value=zS_TYPEINFO.NAME;
			pars[2].Value=zS_TYPEINFO.EXT1;
	
			return DBHelper.ExecuteNonQuery(Save_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Update
		public static int Update(ZS_TYPEINFO zS_TYPEINFO)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@ID",SqlDbType.VarChar),
				new SqlParameter("@NAME",SqlDbType.VarChar),
				new SqlParameter("@EXT1",SqlDbType.Int)
				};
			pars[0].Value=zS_TYPEINFO.ID;
			pars[1].Value=zS_TYPEINFO.NAME;
			pars[2].Value=zS_TYPEINFO.EXT1;
	
			return DBHelper.ExecuteNonQuery(Update_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Delete
		public static int Delete(ZS_TYPEINFO zS_TYPEINFO)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@ID",SqlDbType.VarChar)
				};
			pars[0].Value=zS_TYPEINFO.ID;
	
			return DBHelper.ExecuteNonQuery(Delete_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region FindAll
		public static IList<ZS_TYPEINFO> FindAll()
		{
			return CommonQuery(FindAll_CommandText,CommandType.Text,null);
		}
		#endregion
		
		#region FindById
		public static ZS_TYPEINFO FindById(String iD)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@iD",SqlDbType.VarChar)
			};	
			pars[0].Value = iD;
			IList<ZS_TYPEINFO> list = CommonQuery(FindById_CommandText,CommandType.Text,pars);
			return list.Count > 0 ? list[0] : null;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region CommonQuery
		private static IList<ZS_TYPEINFO> CommonQuery(string commandText, CommandType cmdType, SqlParameter[] pars)
		{
			IList<ZS_TYPEINFO> list = new List<ZS_TYPEINFO>();
			ZS_TYPEINFO zS_TYPEINFO = null;
			
			using (SqlDataReader reader = DBHelper.ExecuteQuery(commandText,cmdType,pars))
           	{
				while(reader.Read())
				{
					zS_TYPEINFO = new ZS_TYPEINFO();
                    if (reader["ID"]==null)
                    {
                        zS_TYPEINFO.ID = "";
                    }
                    else
                    {
                        zS_TYPEINFO.ID = Convert.ToString(reader["ID"]);
                    }

                    if (reader["NAME"]==null)
                    {
                        zS_TYPEINFO.NAME = "";
                    }
                    else
                    {
                        zS_TYPEINFO.NAME = Convert.ToString(reader["NAME"]);
                    }

                    if (reader["EXT1"]==null)
                    {
                        zS_TYPEINFO.EXT1 = 0;
                    }
                    else
                    {
                        zS_TYPEINFO.EXT1 = Convert.ToInt32(reader["EXT1"]);
                    }
					
					
					list.Add(zS_TYPEINFO);
				}
            }
            return list;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
	}
}



